package com.example.javafx.simple;

import javafx.application.Application;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.DialogPane;
import javafx.scene.layout.VBox;
import javafx.scene.control.Label;
import javafx.stage.Stage;

public class DialogPaneExample extends Application {

    @Override
    public void start(Stage primaryStage) {

        Dialog<ButtonType> dialog = new Dialog<>();
        dialog.setTitle("Custom Dialog1");


        // 获取 DialogPane 对象
        DialogPane dialogPane = new DialogPane();
        dialogPane.setHeaderText("Custom Dialog");
        
        // 添加内容到 DialogPane
        VBox content = new VBox();
        content.getChildren().add(new Label("This is a custom dialog!"));
        dialogPane.setContent(content);
        dialogPane.setExpandableContent(new Label("Expandable content goes here."));

        // 添加按钮
        dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

        dialog.setDialogPane(dialogPane);

        // 显示对话框并等待用户响应
        dialog.showAndWait().ifPresent(result ->
                System.out.println("User clicked: " + result));
    }

    public static void main(String[] args) {
        launch(args);
    }
}